import { baseRequestClient, requestClient } from '#/api/request';

export namespace RtIssue {
  export interface Params {
    attr1: null;
  }
  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    rtId: number;
    rtCode: string;
    rtName: null;
    workorderId: number;
    workorderCode: string;
    workstationId: null;
    workstationCode: null;
    workstationName: null;
    rtType: string;
    rtDate: Date;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }
  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getRtIssueTableList = (params: RtIssue.GetListParams) =>
  requestClient.get<RtIssue.GetListReturn>('/mes/wm/rtissue/list', {
    params,
  });
// 增加生产退料
export const addRtIssue = (data: RtIssue.Row) =>
  requestClient.post<RtIssue.GetListReturn>('/mes/wm/rtissue', data);

// 删除生产退料
export const deleteRtIssue = (id: string) =>
  requestClient.delete<RtIssue.GetListReturn>(`/mes/wm/rtissue/${id}`);

// 修改生产退料
export const updateRtIssue = (data: RtIssue.Row) =>
  requestClient.put<RtIssue.GetListReturn>('/mes/wm/rtissue', data);

export const getRtIssueCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/RTISSUE_CODE');
